package com.nervenets.general.service;

import java.util.function.Supplier;

public interface RedisService {
    Boolean hasKey(String key);

    Boolean hexists(String key, String member);

    Long delete(String key);

    Boolean setExpire(String key, int expire);

    Long incrBy(String key, long offset);

    Long incr(String key);

    Boolean hset(String key, String member, String value);

    Boolean set(String key, String value);

    Boolean set(String key, String value, int expire);

    String hget(String key, String member);

    String get(String key);

    Long hdel(String key, String member);

    Long getExpire(String key);

    Boolean canProceedCustom(String key, int expire);

    Boolean setNx(String key, String value);

    Boolean setNx(String key, String value, int expire);

    void clearRedis();

    /**
     * 方法块缓存数据
     *
     * @param cacheKey 缓存key
     * @param executor 方法体
     * @return 缓存数据
     */
    String cache(String cacheKey, Supplier<String> executor);

    String cache(String cacheKey, Supplier<String> executor, int expire);
}
